odibatting2007 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2007odibattingrating.csv")
odibatting2008 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2008odibattingrating.csv")
odibatting2009 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2009odibattingrating.csv")
odibatting2010 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2010odibattingrating.csv")
odibatting2011 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2011odibattingrating.csv")
odibatting2012 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2012odibattingrating.csv")
odibatting2013 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2013odibattingrating.csv")
odibatting2014 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2014odibattingrating.csv")
odibatting2015 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2015odibattingrating.csv")
odibatting2016 <- read.csv("D:\\Vishal\\III year\\Data Analytics\\Assignment II\\Player Ratings\\2016odibattingrating.csv")

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
dataOdiBatting <- bind_rows(odibatting2007, odibatting2008, odibatting2009, odibatting2010,
                            odibatting2011, odibatting2012, odibatting2013, odibatting2014,
                            odibatting2015, odibatting2016)
## Warning in bind_rows_(x, .id): Unequal factor levels: coercing to character
## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector

## Warning in bind_rows_(x, .id): binding character and factor vector,
## coercing into character vector
summary(dataOdiBatting)
##      Name               Rating        LogRating    
##  Length:1000        Min.   :358.0   Min.   :2.554  
##  Class :character   1st Qu.:452.0   1st Qu.:2.655  
##  Mode  :character   Median :518.5   Median :2.715  
##                     Mean   :539.6   Mean   :2.723  
##                     3rd Qu.:617.0   3rd Qu.:2.790  
##                     Max.   :902.0   Max.   :2.955
library(VIM)
## Loading required package: colorspace
## Loading required package: grid
## Loading required package: data.table
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## VIM is ready to use. 
##  Since version 4.0.0 the GUI is in its own package VIMGUI.
## 
##           Please use the package to use the new (and old) GUI.
## Suggestions and bug-reports can be submitted at: https://github.com/alexkowa/VIM/issues
## 
## Attaching package: 'VIM'
## The following object is masked from 'package:datasets':
## 
##     sleep
aggr(dataOdiBatting)

dataOdiBatting <- dataOdiBatting %>%
  group_by(Name) %>%
  summarise(avg = mean(Rating))

set.seed(20)

batcluster <- kmeans(dataOdiBatting[, 2], 5)

batcluster$cluster <- as.factor(batcluster$cluster)

str(batcluster)
## List of 9
##  $ cluster     : Factor w/ 5 levels "1","2","3","4",..: 1 5 3 5 2 5 3 2 5 4 ...
##  $ centers     : num [1:5, 1] 527 722 404 615 463
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:5] "1" "2" "3" "4" ...
##   .. ..$ : chr "avg"
##  $ totss       : num 2410847
##  $ withinss    : num [1:5] 19309 29411 23091 24065 18282
##  $ tot.withinss: num 114158
##  $ betweenss   : num 2296688
##  $ size        : int [1:5] 51 22 63 40 67
##  $ iter        : int 2
##  $ ifault      : int 0
##  - attr(*, "class")= chr "kmeans"
library(ggplot2)

ggplot(dataOdiBatting, aes(dataOdiBatting$Name, avg, color = batcluster$cluster)) +
  geom_point(size = 2) +
  scale_color_hue(labels = c("Good", "Best", "Useless", "Better", "Average")) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  ggtitle("ODI Batting Ratings(2007-2016)")

dat <- arrange(dataOdiBatting, desc(avg)) %>%
  mutate(rank = 1:nrow(dataOdiBatting))

dataOdiBatting <- merge(dataOdiBatting, dat, by  = "Name") 
dataOdiBatting
##                      Name    avg.x    avg.y rank
## 1            Kamran Akmal 521.0000 521.0000   93
## 2            Shoaib Malik 448.0000 448.0000  165
## 3               A A Mulla 369.0000 369.0000  239
## 4              A A Obanda 491.0000 491.0000  115
## 5         A B de Villiers 807.0000 807.0000    1
## 6                 A Bagai 473.0000 473.0000  137
## 7             A Balbirnie 375.0000 375.0000  238
## 8           A C Gilchrist 723.0000 723.0000   10
## 9               A C Voges 482.0000 482.0000  122
## 10              A D Hales 612.0000 612.0000   43
## 11            A D Mathews 586.8571 586.8571   57
## 12            A D Russell 507.0000 507.0000  103
## 13             A Flintoff 550.5000 550.5000   70
## 14              A J Finch 625.0000 625.0000   37
## 15            A J Strauss 544.7500 544.7500   73
## 16             A M Rahane 520.6667 520.6667   94
## 17              A M Samad 420.3333 420.3333  197
## 18               A N Cook 548.7143 548.7143   71
## 19             A R Cusack 396.0000 396.0000  224
## 20              A Symonds 714.5000 714.5000   12
## 21             A T Rayudu 511.0000 511.0000  100
## 22           Abdul Razzaq 480.8000 480.8000  123
## 23            Aftab Ahmed 479.0000 479.0000  127
## 24          Ahmed Shehzad 554.7500 554.7500   68
## 25           Anamul Haque 470.2500 470.2500  141
## 26            Asad Shafiq 461.5000 461.5000  148
## 27       Asghar Stanikzai 421.0000 421.0000  196
## 28              Azhar Ali 491.0000 491.0000  116
## 29             B A Stokes 398.0000 398.0000  220
## 30           B B McCullum 616.5556 616.5556   40
## 31             B J Haddin 504.5714 504.5714  106
## 32              B J Hodge 450.0000 450.0000  162
## 33           B R M Taylor 572.1250 572.1250   62
## 34            B Zuiderent 401.0000 401.0000  216
## 35             Babar Azam 498.0000 498.0000  111
## 36             C A Ingram 447.5000 447.5000  166
## 37              C H Gayle 631.5000 631.5000   34
## 38           C J Anderson 562.3333 562.3333   65
## 39          C J Chibhabha 427.5000 427.5000  187
## 40           C J Ferguson 476.5000 476.5000  131
## 41           C K Coventry 429.0000 429.0000  185
## 42         C K Kapugedera 434.5000 434.5000  180
## 43           C Kieswetter 526.0000 526.0000   89
## 44              C L White 517.4000 517.4000   98
## 45              C O Obuya 448.6667 448.6667  164
## 46             C R Ervine 444.6667 444.6667  168
## 47             D A Miller 544.7500 544.7500   74
## 48             D A Warner 606.8000 606.8000   46
## 49            D J G Sammy 476.8571 476.8571  130
## 50             D J Hussey 480.0000 480.0000  125
## 51            D J J Bravo 472.8750 472.8750  138
## 52            D J Reekers 378.5000 378.5000  235
## 53               D L Hemp 377.0000 377.0000  237
## 54            D L Vettori 419.7500 419.7500  198
## 55              D M Bravo 531.0000 531.0000   85
## 56              D O Obuya 395.5000 395.5000  225
## 57      D P M Jayawardene 632.0000 632.0000   33
## 58              D R Smith 386.0000 386.0000  232
## 59               D Ramdin 429.4000 429.4000  184
## 60              D S Smith 415.0000 415.0000  203
## 61           D T Johnston 359.5000 359.5000  243
## 62              E C Joyce 476.5000 476.5000  132
## 63           E Chigumbura 496.3000 496.3000  113
## 64           E J G Morgan 608.3750 608.3750   45
## 65       E S Szwarczynski 413.0000 413.0000  206
## 66            F Behardien 457.5000 457.5000  156
## 67           F du Plessis 586.8000 586.8000   58
## 68             Fawad Alam 413.6667 413.6667  205
## 69               G B Hogg 379.0000 379.0000  234
## 70              G C Smith 686.1429 686.1429   20
## 71             G C Wilson 460.1667 460.1667  152
## 72            G D Elliott 475.7500 475.7500  135
## 73              G Gambhir 625.0000 625.0000   38
## 74             G J Bailey 655.2000 655.2000   24
## 75            G J Maxwell 603.2500 603.2500   48
## 76           G M Hamilton 470.0000 470.0000  142
## 77              G O Jones 426.5000 426.5000  189
## 78             G W Flower 414.5000 414.5000  204
## 79       H D R Thirimanne 520.2000 520.2000   95
## 80              H H Gibbs 696.0000 696.0000   15
## 81               H M Amla 789.0000 789.0000    2
## 82            H Masakadza 480.2000 480.2000  124
## 83           Haris Sohail 499.5000 499.5000  109
## 84            I H Romaine 361.0000 361.0000  242
## 85            I J L Trott 751.3333 751.3333    5
## 86             I K Pathan 421.3333 421.3333  195
## 87               I R Bell 599.3750 599.3750   50
## 88          I S Billcliff 398.0000 398.0000  221
## 89           Imran Farhat 423.6667 423.6667  191
## 90            Imran Nazir 391.0000 391.0000  231
## 91            Imrul Kayes 470.8333 470.8333  140
## 92            J C Buttler 641.3333 641.3333   31
## 93              J Charles 539.7500 539.7500   77
## 94             J D P Oram 508.3333 508.3333  102
## 95              J D Ryder 500.6667 500.6667  108
## 96               J E Root 634.2500 634.2500   32
## 97             J F Mooney 405.2000 405.2000  211
## 98             J H Kallis 672.8750 672.8750   22
## 99                J J Roy 534.0000 534.0000   82
## 100           J M Davison 412.0000 412.0000  208
## 101               J M How 522.0000 522.0000   92
## 102              J M Kemp 573.0000 573.0000   61
## 103             J Mubarak 403.0000 403.0000  215
## 104            J O Holder 405.0000 405.0000  212
## 105            J P Duminy 593.1111 593.1111   53
## 106          J P Faulkner 585.3333 585.3333   59
## 107             J R Hopes 469.0000 469.0000  144
## 108          J W A Taylor 447.0000 447.0000  167
## 109          Javed Ahmadi 378.0000 378.0000  236
## 110       Junaid Siddique 477.0000 477.0000  129
## 111           K A Pollard 522.6667 522.6667   91
## 112        K C Sangakkara 736.3750 736.3750    8
## 113           K J Coetzer 450.7500 450.7500  161
## 114           K J O'Brien 513.9000 513.9000   99
## 115 K K K K K K D Karthik 432.3333 432.3333  181
## 116          K O A Powell 405.0000 405.0000  213
## 117         K P Pietersen 649.4286 649.4286   26
## 118        K S Williamson 664.4000 664.4000   23
## 119          Kamran Akmal 497.8000 497.8000  112
## 120          Khurram Khan 416.0000 416.0000  200
## 121         L D Chandimal 547.2000 547.2000   72
## 122            L J Wright 416.0000 416.0000  201
## 123         L M P Simmons 544.0000 544.0000   75
## 124            L O B Cann 443.0000 443.0000  169
## 125           L P C Silva 519.2000 519.2000   97
## 126            L R Taylor 646.5000 646.5000   28
## 127              L Ronchi 526.5000 526.5000   88
## 128             L Vincent 530.0000 530.0000   87
## 129        M D K J Perera 476.3333 476.3333  133
## 130          M E K Hussey 742.0000 742.0000    6
## 131          M F Maharoof 393.3333 393.3333  229
## 132            M J Clarke 690.6250 690.6250   17
## 133           M J Guptill 631.3750 631.3750   35
## 134             M J Prior 442.5000 442.5000  171
## 135           M J Santner 405.0000 405.0000  214
## 136            M L Hayden 738.0000 738.0000    7
## 137           M N Samuels 492.2000 492.2000  114
## 138            M N Waller 431.6667 431.6667  183
## 139             M R Marsh 535.5000 535.5000   79
## 140             M S Dhoni 752.4000 752.4000    4
## 141          M S Sinclair 395.5000 395.5000  226
## 142              M S Wade 428.7500 428.7500  186
## 143          M T Thushara 394.0000 394.0000  227
## 144           M V Boucher 551.6000 551.6000   69
## 145            M W Machan 438.0000 438.0000  176
## 146           Mahmudullah 501.5714 501.5714  107
## 147      Mashrafe Mortaza 368.0000 368.0000  240
## 148         Misbah ul Haq 610.7143 610.7143   44
## 149             Moeen Ali 449.0000 449.0000  163
## 150     Mohammad Ashraful 479.2000 479.2000  126
## 151       Mohammad Hafeez 587.5000 587.5000   56
## 152         Mohammad Nabi 458.8000 458.8000  155
## 153      Mohammad Shahzad 441.0000 441.0000  174
## 154       Mohammad Yousuf 682.7500 682.7500   21
## 155         Mominul Haque 392.0000 392.0000  230
## 156       Mushfiqur Rahim 530.2500 530.2500   86
## 157           N Deonarine 438.0000 438.0000  177
## 158           N J O'Brien 460.1000 460.1000  153
## 159          N L McCullum 422.0000 422.0000  192
## 160          N L T Perera 396.5000 396.5000  223
## 161           Naeem Islam 415.5000 415.5000  202
## 162         Nasir Hossain 555.4000 555.4000   67
## 163         Nasir Jamshed 469.5000 469.5000  143
## 164       Noor Ali Zadran 421.5000 421.5000  193
## 165         Nowroz Mangal 441.0000 441.0000  175
## 166              O A Shah 562.0000 562.0000   66
## 167             P A Patel 417.0000 417.0000  199
## 168       P D Collingwood 644.5000 644.5000   30
## 169            P G Fulton 596.0000 596.0000   51
## 170            P J Hughes 506.5000 506.5000  104
## 171           P L Mommsen 401.0000 401.0000  217
## 172          P R Stirling 615.6667 615.6667   41
## 173            P W Borren 408.0000 408.0000  209
## 174             Q de Kock 692.6667 692.6667   16
## 175            R A Jadeja 488.5000 488.5000  118
## 176        R D Berrington 443.0000 443.0000  170
## 177              R Dravid 563.7500 563.7500   64
## 178            R G Sharma 563.7778 563.7778   63
## 179             R J Nicol 427.0000 427.0000  188
## 180     R N ten Doeschate 519.2500 519.2500   96
## 181           R R Rossouw 487.0000 487.0000  119
## 182            R R Sarwan 626.8333 626.8333   36
## 183            R R Watson 394.0000 394.0000  228
## 184            R S Bopara 476.3333 476.3333  134
## 185            R S Morton 498.3333 498.3333  110
## 186           R T Ponting 723.2000 723.2000    9
## 187           R V Uthappa 441.6667 441.6667  172
## 188         Raqibul Hasan 459.0000 459.0000  154
## 189         Rizwan Cheema 425.0000 425.0000  190
## 190            S B Styris 614.2500 614.2500   42
## 191           S C Ganguly 536.0000 536.0000   78
## 192          S C Williams 477.9000 477.9000  128
## 193         S Chanderpaul 715.7500 715.7500   11
## 194         S Chattergoon 363.0000 363.0000  241
## 195            S Dhaniram 412.3333 412.3333  207
## 196              S Dhawan 703.2500 703.2500   14
## 197             S E Marsh 484.0000 484.0000  121
## 198        S H T Kandamby 452.6667 452.6667  158
## 199             S K Raina 581.2000 581.2000   60
## 200       S M A Priyanjan 406.0000 406.0000  210
## 201           S M Pollock 540.0000 540.0000   76
## 202        S Matsikenyeri 452.8000 452.8000  157
## 203            S O Tikolo 451.2857 451.2857  160
## 204           S P D Smith 689.5000 689.5000   18
## 205         S R Tendulkar 707.0000 707.0000   13
## 206            S R Watson 616.8000 616.8000   39
## 207        S T Jayasuriya 647.0000 647.0000   27
## 208         Sabbir Rahman 436.5000 436.5000  178
## 209           Salman Butt 589.0000 589.0000   55
## 210    Samiullah Shenwari 504.6667 504.6667  105
## 211         Sarfraz Ahmed 460.5000 460.5000  151
## 212         Shahid Afridi 535.5000 535.5000   80
## 213       Shahriar Nafees 464.7500 464.7500  146
## 214         Shaiman Anwar 461.5000 461.5000  149
## 215       Shakib Al Hasan 594.1000 594.1000   52
## 216        Shamsur Rahman 398.0000 398.0000  222
## 217          Shoaib Malik 531.2222 531.2222   84
## 218         Sikandar Raza 490.5000 490.5000  117
## 219        Sohaib Maqsood 441.6667 441.6667  173
## 220         Soumya Sarkar 600.0000 600.0000   49
## 221             T D Paine 432.0000 432.0000  182
## 222          T L W Cooper 533.3333 533.3333   83
## 223           T M Dilshan 687.3000 687.3000   19
## 224             T M Odoyo 421.4286 421.4286  194
## 225              T Mishra 464.5000 464.5000  147
## 226           T T Bresnan 399.0000 399.0000  219
## 227       T T Samaraweera 485.0000 485.0000  120
## 228               T Taibu 469.0000 469.0000  145
## 229          T W M Latham 475.0000 475.0000  136
## 230           Tamim Iqbal 590.6667 590.6667   54
## 231           U T Khawaja 435.0000 435.0000  179
## 232            Umar Akmal 605.7143 605.7143   47
## 233               V Kohli 788.0000 788.0000    3
## 234              V Sehwag 646.0000 646.0000   29
## 235             V Sibanda 460.8750 460.8750  150
## 236             W Barresi 386.0000 386.0000  233
## 237     W T S Porterfield 471.4444 471.4444  139
## 238          W U Tharanga 509.7000 509.7000  101
## 239             W W Hinds 401.0000 401.0000  218
## 240            Y K Pathan 451.5000 451.5000  159
## 241          Yasir Hameed 535.0000 535.0000   81
## 242           Younis Khan 523.1111 523.1111   90
## 243          Yuvraj Singh 652.2857 652.2857   25
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
p <- plot_ly(dataOdiBatting, x = ~Name, y = ~avg.x, type = 'scatter', 
             mode = 'markers', color = batcluster$cluster, 
             text = ~paste('Rank: ', rank))

p
p <- plot_ly(dataOdiBatting, x = ~Name, y = ~avg.x, type = 'scatter', mode = 'markers', name = 'G1') %>%
  add_trace(y = ~avg.x, name = 'Tree 2') %>%
  add_trace(y = ~avg.x, name = 'Tree 3') %>%
  add_trace(y = ~avg.x, name = 'Tree 4') %>%
  add_trace(y = ~avg.x, name = 'Tree 5')
p
dat
## # A tibble: 243 x 3
##    Name              avg  rank
##    <chr>           <dbl> <int>
##  1 A B de Villiers  807      1
##  2 H M Amla         789      2
##  3 V Kohli          788      3
##  4 M S Dhoni        752.     4
##  5 I J L Trott      751.     5
##  6 M E K Hussey     742      6
##  7 M L Hayden       738      7
##  8 K C Sangakkara   736.     8
##  9 R T Ponting      723.     9
## 10 A C Gilchrist    723     10
## # ... with 233 more rows
#Classification 

library(party)
## Loading required package: mvtnorm
## Loading required package: modeltools
## Loading required package: stats4
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
new_dat <- sample(2, nrow(dat), replace = TRUE, prob = c(0.7, 0.3))
train_data <- dat[new_dat == 1, ]
test_data <- dat[new_dat == 2, ]

myf <- avg~ rank
tree <- ctree(myf, data = train_data)
table(predict(tree), train_data$avg)
##                   
##                    359.5 369 375 378.5 379 386 391 393.333333333333 394
##   376.142857142857     1   1   1     1   1   2   0                0   0
##   397.217948717949     0   0   0     0   0   0   1                1   2
##   422.862464985994     0   0   0     0   0   0   0                0   0
##   445.309693877551     0   0   0     0   0   0   0                0   0
##   463.836507936508     0   0   0     0   0   0   0                0   0
##   479.570346320346     0   0   0     0   0   0   0                0   0
##   492.514814814815     0   0   0     0   0   0   0                0   0
##   524.119692460317     0   0   0     0   0   0   0                0   0
##   553.58544973545      0   0   0     0   0   0   0                0   0
##   588.396472663139     0   0   0     0   0   0   0                0   0
##   613.148214285714     0   0   0     0   0   0   0                0   0
##   643.287261904762     0   0   0     0   0   0   0                0   0
##   719.349553571429     0   0   0     0   0   0   0                0   0
##                   
##                    395.5 396 396.5 398 401 405 406 412 413 415 416 417
##   376.142857142857     0   0     0   0   0   0   0   0   0   0   0   0
##   397.217948717949     2   1     1   2   1   1   1   0   0   0   0   0
##   422.862464985994     0   0     0   0   0   0   0   1   1   1   1   1
##   445.309693877551     0   0     0   0   0   0   0   0   0   0   0   0
##   463.836507936508     0   0     0   0   0   0   0   0   0   0   0   0
##   479.570346320346     0   0     0   0   0   0   0   0   0   0   0   0
##   492.514814814815     0   0     0   0   0   0   0   0   0   0   0   0
##   524.119692460317     0   0     0   0   0   0   0   0   0   0   0   0
##   553.58544973545      0   0     0   0   0   0   0   0   0   0   0   0
##   588.396472663139     0   0     0   0   0   0   0   0   0   0   0   0
##   613.148214285714     0   0     0   0   0   0   0   0   0   0   0   0
##   643.287261904762     0   0     0   0   0   0   0   0   0   0   0   0
##   719.349553571429     0   0     0   0   0   0   0   0   0   0   0   0
##                   
##                    419.75 421.333333333333 421.428571428571 421.5 422
##   376.142857142857      0                0                0     0   0
##   397.217948717949      0                0                0     0   0
##   422.862464985994      1                1                1     1   1
##   445.309693877551      0                0                0     0   0
##   463.836507936508      0                0                0     0   0
##   479.570346320346      0                0                0     0   0
##   492.514814814815      0                0                0     0   0
##   524.119692460317      0                0                0     0   0
##   553.58544973545       0                0                0     0   0
##   588.396472663139      0                0                0     0   0
##   613.148214285714      0                0                0     0   0
##   643.287261904762      0                0                0     0   0
##   719.349553571429      0                0                0     0   0
##                   
##                    426.5 428.75 429 429.4 431.666666666667 432
##   376.142857142857     0      0   0     0                0   0
##   397.217948717949     0      0   0     0                0   0
##   422.862464985994     1      1   1     1                1   1
##   445.309693877551     0      0   0     0                0   0
##   463.836507936508     0      0   0     0                0   0
##   479.570346320346     0      0   0     0                0   0
##   492.514814814815     0      0   0     0                0   0
##   524.119692460317     0      0   0     0                0   0
##   553.58544973545      0      0   0     0                0   0
##   588.396472663139     0      0   0     0                0   0
##   613.148214285714     0      0   0     0                0   0
##   643.287261904762     0      0   0     0                0   0
##   719.349553571429     0      0   0     0                0   0
##                   
##                    432.333333333333 435 436.5 441.666666666667 442.5 443
##   376.142857142857                0   0     0                0     0   0
##   397.217948717949                0   0     0                0     0   0
##   422.862464985994                1   0     0                0     0   0
##   445.309693877551                0   1     1                1     1   2
##   463.836507936508                0   0     0                0     0   0
##   479.570346320346                0   0     0                0     0   0
##   492.514814814815                0   0     0                0     0   0
##   524.119692460317                0   0     0                0     0   0
##   553.58544973545                 0   0     0                0     0   0
##   588.396472663139                0   0     0                0     0   0
##   613.148214285714                0   0     0                0     0   0
##   643.287261904762                0   0     0                0     0   0
##   719.349553571429                0   0     0                0     0   0
##                   
##                    444.666666666667 447 447.5 448.666666666667 450 450.75
##   376.142857142857                0   0     0                0   0      0
##   397.217948717949                0   0     0                0   0      0
##   422.862464985994                0   0     0                0   0      0
##   445.309693877551                1   1     1                1   1      1
##   463.836507936508                0   0     0                0   0      0
##   479.570346320346                0   0     0                0   0      0
##   492.514814814815                0   0     0                0   0      0
##   524.119692460317                0   0     0                0   0      0
##   553.58544973545                 0   0     0                0   0      0
##   588.396472663139                0   0     0                0   0      0
##   613.148214285714                0   0     0                0   0      0
##   643.287261904762                0   0     0                0   0      0
##   719.349553571429                0   0     0                0   0      0
##                   
##                    451.285714285714 452.8 457.5 459 460.1 460.166666666667
##   376.142857142857                0     0     0   0     0                0
##   397.217948717949                0     0     0   0     0                0
##   422.862464985994                0     0     0   0     0                0
##   445.309693877551                1     1     0   0     0                0
##   463.836507936508                0     0     1   1     1                1
##   479.570346320346                0     0     0   0     0                0
##   492.514814814815                0     0     0   0     0                0
##   524.119692460317                0     0     0   0     0                0
##   553.58544973545                 0     0     0   0     0                0
##   588.396472663139                0     0     0   0     0                0
##   613.148214285714                0     0     0   0     0                0
##   643.287261904762                0     0     0   0     0                0
##   719.349553571429                0     0     0   0     0                0
##                   
##                    460.5 460.875 461.5 464.5 464.75 469 470
##   376.142857142857     0       0     0     0      0   0   0
##   397.217948717949     0       0     0     0      0   0   0
##   422.862464985994     0       0     0     0      0   0   0
##   445.309693877551     0       0     0     0      0   0   0
##   463.836507936508     1       1     2     1      1   1   1
##   479.570346320346     0       0     0     0      0   0   0
##   492.514814814815     0       0     0     0      0   0   0
##   524.119692460317     0       0     0     0      0   0   0
##   553.58544973545      0       0     0     0      0   0   0
##   588.396472663139     0       0     0     0      0   0   0
##   613.148214285714     0       0     0     0      0   0   0
##   643.287261904762     0       0     0     0      0   0   0
##   719.349553571429     0       0     0     0      0   0   0
##                   
##                    471.444444444444 472.875 475.75 476.333333333333
##   376.142857142857                0       0      0                0
##   397.217948717949                0       0      0                0
##   422.862464985994                0       0      0                0
##   445.309693877551                0       0      0                0
##   463.836507936508                1       1      0                0
##   479.570346320346                0       0      1                2
##   492.514814814815                0       0      0                0
##   524.119692460317                0       0      0                0
##   553.58544973545                 0       0      0                0
##   588.396472663139                0       0      0                0
##   613.148214285714                0       0      0                0
##   643.287261904762                0       0      0                0
##   719.349553571429                0       0      0                0
##                   
##                    476.857142857143 479 479.2 480 480.8 482 484 485 487
##   376.142857142857                0   0     0   0     0   0   0   0   0
##   397.217948717949                0   0     0   0     0   0   0   0   0
##   422.862464985994                0   0     0   0     0   0   0   0   0
##   445.309693877551                0   0     0   0     0   0   0   0   0
##   463.836507936508                0   0     0   0     0   0   0   0   0
##   479.570346320346                1   1     1   1     1   1   1   1   0
##   492.514814814815                0   0     0   0     0   0   0   0   1
##   524.119692460317                0   0     0   0     0   0   0   0   0
##   553.58544973545                 0   0     0   0     0   0   0   0   0
##   588.396472663139                0   0     0   0     0   0   0   0   0
##   613.148214285714                0   0     0   0     0   0   0   0   0
##   643.287261904762                0   0     0   0     0   0   0   0   0
##   719.349553571429                0   0     0   0     0   0   0   0   0
##                   
##                    488.5 490.5 491 492.2 496.3 497.8 498.333333333333
##   376.142857142857     0     0   0     0     0     0                0
##   397.217948717949     0     0   0     0     0     0                0
##   422.862464985994     0     0   0     0     0     0                0
##   445.309693877551     0     0   0     0     0     0                0
##   463.836507936508     0     0   0     0     0     0                0
##   479.570346320346     0     0   0     0     0     0                0
##   492.514814814815     1     1   2     1     1     1                1
##   524.119692460317     0     0   0     0     0     0                0
##   553.58544973545      0     0   0     0     0     0                0
##   588.396472663139     0     0   0     0     0     0                0
##   613.148214285714     0     0   0     0     0     0                0
##   643.287261904762     0     0   0     0     0     0                0
##   719.349553571429     0     0   0     0     0     0                0
##                   
##                    501.571428571429 504.571428571429 509.7 511 517.4 520.2
##   376.142857142857                0                0     0   0     0     0
##   397.217948717949                0                0     0   0     0     0
##   422.862464985994                0                0     0   0     0     0
##   445.309693877551                0                0     0   0     0     0
##   463.836507936508                0                0     0   0     0     0
##   479.570346320346                0                0     0   0     0     0
##   492.514814814815                0                0     0   0     0     0
##   524.119692460317                1                1     1   1     1     1
##   553.58544973545                 0                0     0   0     0     0
##   588.396472663139                0                0     0   0     0     0
##   613.148214285714                0                0     0   0     0     0
##   643.287261904762                0                0     0   0     0     0
##   719.349553571429                0                0     0   0     0     0
##                   
##                    520.666666666667 530 530.25 531 531.222222222222
##   376.142857142857                0   0      0   0                0
##   397.217948717949                0   0      0   0                0
##   422.862464985994                0   0      0   0                0
##   445.309693877551                0   0      0   0                0
##   463.836507936508                0   0      0   0                0
##   479.570346320346                0   0      0   0                0
##   492.514814814815                0   0      0   0                0
##   524.119692460317                1   1      1   1                1
##   553.58544973545                 0   0      0   0                0
##   588.396472663139                0   0      0   0                0
##   613.148214285714                0   0      0   0                0
##   643.287261904762                0   0      0   0                0
##   719.349553571429                0   0      0   0                0
##                   
##                    533.333333333333 534 535 536 540 544 544.75 547.2
##   376.142857142857                0   0   0   0   0   0      0     0
##   397.217948717949                0   0   0   0   0   0      0     0
##   422.862464985994                0   0   0   0   0   0      0     0
##   445.309693877551                0   0   0   0   0   0      0     0
##   463.836507936508                0   0   0   0   0   0      0     0
##   479.570346320346                0   0   0   0   0   0      0     0
##   492.514814814815                0   0   0   0   0   0      0     0
##   524.119692460317                1   1   1   1   1   0      0     0
##   553.58544973545                 0   0   0   0   0   1      2     1
##   588.396472663139                0   0   0   0   0   0      0     0
##   613.148214285714                0   0   0   0   0   0      0     0
##   643.287261904762                0   0   0   0   0   0      0     0
##   719.349553571429                0   0   0   0   0   0      0     0
##                   
##                    548.714285714286 551.6 554.75 555.4 562
##   376.142857142857                0     0      0     0   0
##   397.217948717949                0     0      0     0   0
##   422.862464985994                0     0      0     0   0
##   445.309693877551                0     0      0     0   0
##   463.836507936508                0     0      0     0   0
##   479.570346320346                0     0      0     0   0
##   492.514814814815                0     0      0     0   0
##   524.119692460317                0     0      0     0   0
##   553.58544973545                 1     1      1     1   1
##   588.396472663139                0     0      0     0   0
##   613.148214285714                0     0      0     0   0
##   643.287261904762                0     0      0     0   0
##   719.349553571429                0     0      0     0   0
##                   
##                    562.333333333333 563.75 563.777777777778 573
##   376.142857142857                0      0                0   0
##   397.217948717949                0      0                0   0
##   422.862464985994                0      0                0   0
##   445.309693877551                0      0                0   0
##   463.836507936508                0      0                0   0
##   479.570346320346                0      0                0   0
##   492.514814814815                0      0                0   0
##   524.119692460317                0      0                0   0
##   553.58544973545                 1      1                1   0
##   588.396472663139                0      0                0   1
##   613.148214285714                0      0                0   0
##   643.287261904762                0      0                0   0
##   719.349553571429                0      0                0   0
##                   
##                    585.333333333333 586.857142857143 587.5 589
##   376.142857142857                0                0     0   0
##   397.217948717949                0                0     0   0
##   422.862464985994                0                0     0   0
##   445.309693877551                0                0     0   0
##   463.836507936508                0                0     0   0
##   479.570346320346                0                0     0   0
##   492.514814814815                0                0     0   0
##   524.119692460317                0                0     0   0
##   553.58544973545                 0                0     0   0
##   588.396472663139                1                1     1   1
##   613.148214285714                0                0     0   0
##   643.287261904762                0                0     0   0
##   719.349553571429                0                0     0   0
##                   
##                    590.666666666667 593.111111111111 594.1 596 599.375
##   376.142857142857                0                0     0   0       0
##   397.217948717949                0                0     0   0       0
##   422.862464985994                0                0     0   0       0
##   445.309693877551                0                0     0   0       0
##   463.836507936508                0                0     0   0       0
##   479.570346320346                0                0     0   0       0
##   492.514814814815                0                0     0   0       0
##   524.119692460317                0                0     0   0       0
##   553.58544973545                 0                0     0   0       0
##   588.396472663139                1                1     1   1       0
##   613.148214285714                0                0     0   0       1
##   643.287261904762                0                0     0   0       0
##   719.349553571429                0                0     0   0       0
##                   
##                    603.25 605.714285714286 606.8 608.375 610.714285714286
##   376.142857142857      0                0     0       0                0
##   397.217948717949      0                0     0       0                0
##   422.862464985994      0                0     0       0                0
##   445.309693877551      0                0     0       0                0
##   463.836507936508      0                0     0       0                0
##   479.570346320346      0                0     0       0                0
##   492.514814814815      0                0     0       0                0
##   524.119692460317      0                0     0       0                0
##   553.58544973545       0                0     0       0                0
##   588.396472663139      0                0     0       0                0
##   613.148214285714      1                1     1       1                1
##   643.287261904762      0                0     0       0                0
##   719.349553571429      0                0     0       0                0
##                   
##                    614.25 615.666666666667 616.8 625 626.833333333333
##   376.142857142857      0                0     0   0                0
##   397.217948717949      0                0     0   0                0
##   422.862464985994      0                0     0   0                0
##   445.309693877551      0                0     0   0                0
##   463.836507936508      0                0     0   0                0
##   479.570346320346      0                0     0   0                0
##   492.514814814815      0                0     0   0                0
##   524.119692460317      0                0     0   0                0
##   553.58544973545       0                0     0   0                0
##   588.396472663139      0                0     0   0                0
##   613.148214285714      1                1     1   2                1
##   643.287261904762      0                0     0   0                0
##   719.349553571429      0                0     0   0                0
##                   
##                    631.375 631.5 634.25 641.333333333333 644.5 646 647
##   376.142857142857       0     0      0                0     0   0   0
##   397.217948717949       0     0      0                0     0   0   0
##   422.862464985994       0     0      0                0     0   0   0
##   445.309693877551       0     0      0                0     0   0   0
##   463.836507936508       0     0      0                0     0   0   0
##   479.570346320346       0     0      0                0     0   0   0
##   492.514814814815       0     0      0                0     0   0   0
##   524.119692460317       0     0      0                0     0   0   0
##   553.58544973545        0     0      0                0     0   0   0
##   588.396472663139       0     0      0                0     0   0   0
##   613.148214285714       0     0      0                0     0   0   0
##   643.287261904762       1     1      1                1     1   1   1
##   719.349553571429       0     0      0                0     0   0   0
##                   
##                    649.428571428571 652.285714285714 655.2 682.75
##   376.142857142857                0                0     0      0
##   397.217948717949                0                0     0      0
##   422.862464985994                0                0     0      0
##   445.309693877551                0                0     0      0
##   463.836507936508                0                0     0      0
##   479.570346320346                0                0     0      0
##   492.514814814815                0                0     0      0
##   524.119692460317                0                0     0      0
##   553.58544973545                 0                0     0      0
##   588.396472663139                0                0     0      0
##   613.148214285714                0                0     0      0
##   643.287261904762                1                1     1      0
##   719.349553571429                0                0     0      1
##                   
##                    686.142857142857 687.3 689.5 690.625 692.666666666667
##   376.142857142857                0     0     0       0                0
##   397.217948717949                0     0     0       0                0
##   422.862464985994                0     0     0       0                0
##   445.309693877551                0     0     0       0                0
##   463.836507936508                0     0     0       0                0
##   479.570346320346                0     0     0       0                0
##   492.514814814815                0     0     0       0                0
##   524.119692460317                0     0     0       0                0
##   553.58544973545                 0     0     0       0                0
##   588.396472663139                0     0     0       0                0
##   613.148214285714                0     0     0       0                0
##   643.287261904762                0     0     0       0                0
##   719.349553571429                1     1     1       1                1
##                   
##                    703.25 707 714.5 715.75 723 736.375 751.333333333333
##   376.142857142857      0   0     0      0   0       0                0
##   397.217948717949      0   0     0      0   0       0                0
##   422.862464985994      0   0     0      0   0       0                0
##   445.309693877551      0   0     0      0   0       0                0
##   463.836507936508      0   0     0      0   0       0                0
##   479.570346320346      0   0     0      0   0       0                0
##   492.514814814815      0   0     0      0   0       0                0
##   524.119692460317      0   0     0      0   0       0                0
##   553.58544973545       0   0     0      0   0       0                0
##   588.396472663139      0   0     0      0   0       0                0
##   613.148214285714      0   0     0      0   0       0                0
##   643.287261904762      0   0     0      0   0       0                0
##   719.349553571429      1   1     1      1   1       1                1
##                   
##                    752.4 788 789
##   376.142857142857     0   0   0
##   397.217948717949     0   0   0
##   422.862464985994     0   0   0
##   445.309693877551     0   0   0
##   463.836507936508     0   0   0
##   479.570346320346     0   0   0
##   492.514814814815     0   0   0
##   524.119692460317     0   0   0
##   553.58544973545      0   0   0
##   588.396472663139     0   0   0
##   613.148214285714     0   0   0
##   643.287261904762     0   0   0
##   719.349553571429     1   1   1
plot(tree)

test_tree <- ctree(myf, data = test_data)
plot(test_tree)